var app = getApp()
Page({
  data: {
    page: 1
  },
  detail(e) {
    console.log(e)
    wx.navigateTo({
      url: '/pages/basics/food/detail?id=' + e.currentTarget.dataset.code
    })
  },
  loadMore: function (e) {
    var that = this;
    this.setData({
      isLoad: true
    })
    setTimeout(function () {
      var that = this
      wx.showToast({
          title: '到底了',
        })

    }, 1000);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
    })
    var that = this;
      console.log("page, jwt", app.globalData.jwt)
      if (wx.getStorageSync('user_id')){
        wx.request({
          url: "http://" + app.globalData.url + "/user/history/",
          method: 'GET',
          header: {
            'Accept': 'application/json',
            "jwt": app.globalData.jwt
          },
          data: {
              "user_id": wx.getStorageSync('user_id')
          },
          success: function (res) {
            that.setData({
              list: res.data.data,
            })
          }
        })
  
      }else{
        wx.showToast({
          title: '请先登录',
          icon: "none"
        })
      }

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
      console.log("下拉")
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this
    console.log("that.data.pages", that.data.pages, that.data.page)
      wx.showToast({
        title: '到底了',
      })



  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
